﻿<%@codepage="65001"%>
<%Session.CodePage=65001%>
<!--#include file="log.asp" -->
<%
Class datebase

	Private conn
	Private access

	Private Sub Class_Initialize
		Call connent
	End Sub

	Private Sub Class_Terminate
		conn.close
		Set conn = Nothing
	End Sub

	Private Sub connent()
		Dim str
		str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/core/data/#db.mdb")
		Set conn=server.createobject("ADODB.connection")
		conn.open str
	End Sub

	Public Function query(sql)
		On Error Resume Next
		Dim rs
		Set rs=server.createobject("adodb.recordset")
		rs.CursorLocation = 3
		rs.open sql,conn,1,3
		if Err.Number <> 0 then
			lg.Write("错误编号：" & Err.Number)
			lg.Write("错误信息：" & Err.Description)
			lg.Write("SQL语句：" & sql)
			response.End()
		end if
		Set query = rs
		Set rs = nothing
	End Function

	Public Sub execute(sql)
		On Error Resume Next
		conn.execute(sql)
		if Err.Number <> 0 then
			lg.Write("错误编号：" & Err.Number)
			lg.Write("错误信息：" & Err.Description)
			lg.Write("SQL语句：" & sql)
			response.End()
		end if
	End Sub

End Class

dim db
set db = new datebase
%>
